<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        对象中方法的使用
        let obj = {
            name: 'HUAWEI',
            han: function (a, b) {
                return a + b
            },
            fn: function (str, zbc) {
                return document.write(`${str}，${zbc}`)
            },
            decce: function () {
                document.write('我会跳舞')
            }


        }
        // 调用对象中的方法 传递参数
        console.log(obj.han(18, 20));
        console.log(obj.fn('好的', '真不错'));
        console.log(obj.decce());

        let lm = {
            name: '爱哦尼亚',
            age: 18,
            fn: function (a, b) {
                document.write(`我会${a},又会${b}`)
            }
        }
        lm.fn('唱歌', '跳舞')

        //遍历对象
        for (let key in lm) {
            console.log(key);
            console.log(lm[key]);
        }

        let students = [
            { name: '小明', age: 18, gender: '男', hometown: '河北省' },
            { name: '小红', age: 19, gender: '女', hometown: '河南省' },
            { name: '小刚', age: 17, gender: '男', hometown: '山西省' },
            { name: '小丽', age: 18, gender: '女', hometown: '山东省' }
        ]
        // -------------------------
        // 遍历数组中的对象
        for (let [i, item] of students.entries()) {
            // console.log(item);
            // console.log(item.name);
        }
        for (let i = 0; i < students.length; i++) {
            console.log(i);
            // console.log(students[i]);
            // console.log(students[i].name);
            // console.log(students[i].hometown);
        }
    </script>
</body>

</html>